#include "Integer.h"

Integer::Integer(const char* c_str)
{
	ii = atoi(c_str);
}

Integer::Integer(const Integer& rhs)
{
	ii = rhs.value();
}

void Integer::operator=(const Integer& rhs)
{
	ii = rhs.value();
}

void Integer::operator=(int rhs)
{
	ii = rhs;
}

string Integer::toString() const
{
	return to_string(ii);
}

Integer::operator int() const
{
	int tmp = value();
	return tmp;
}

Integer::operator double() const
{
	double tmp = value();
	return tmp;
}

Integer::operator char() const
{
	char tmp = value();
	return tmp;
}

int Integer::cmp(const Integer& rhs)
{
	if (ii < rhs.value())
		return -1;
	if (ii > rhs.value())
		return 1;
	return 0;

}

int Integer::parse(const char* c_str)
{
	return atoi(c_str);
}

Integer& Integer::operator+(const Integer& a)
{
	Integer* tmp = new Integer(ii + a.value());
	return *tmp;
}

Integer& Integer::operator-(const Integer& a)
{
	Integer* tmp = new Integer(ii - a.value());
	return *tmp;
}

Integer& Integer::operator*(const Integer& a)
{
	Integer* tmp = new Integer(ii * a.value());
	return *tmp;
}

Integer& Integer::operator/(const Integer& a)
{
	Integer* tmp = new Integer(ii / a.value());
	return *tmp;
}

Integer& Integer::operator+=(const Integer& a)
{
	this->ii += a.value();
	return *this;
}

Integer& Integer::operator-=(const Integer& a)
{
	this->ii -= a.value();
	return *this;
}

Integer& Integer::operator*=(const Integer& a)
{
	this->ii *= a.value();
	return *this;
}

Integer& Integer::operator/=(const Integer& a)
{
	this->ii /= a.value();
	return *this;
}

Integer& Integer::operator++()
{
	this->ii += 1;
	return *this;
}

Integer& Integer::operator++(int)
{
	Integer* tmp = new Integer(ii);
	ii++;
	return *tmp;
}

Integer& Integer::operator--()
{
	ii--;
	return *this;
}

Integer& Integer::operator--(int)
{
	Integer* tmp = new Integer(ii);
	ii--;
	return *tmp;
}

ostream& operator<<(ostream& oo, Integer v)
{
	oo << v.value();
	return oo;
}
